import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:largefriends/res.dart';
import 'package:largefriends/res/lf_color.dart';
import 'package:largefriends/res/lf_double_ext.dart';
import 'package:largefriends/res/lf_fonts.dart';
import 'package:largefriends/res/lf_text_style.dart';
import 'package:largefriends/res/strings/lf_strings.dart';
import 'package:largefriends/utils/lf_dialog_utils.dart';
import 'package:largefriends/widgets/lf_button.dart';

Future showActionTips({
  required String tips,
  Widget? tipWidget,
  String? actionButtonTip,
  required Function() action,
  bool showCancel = true,
  bool dismissible = true,
}) async {
  await Get.bottomSheet(
    WillPopScope(
      child: Padding(
        padding: EdgeInsets.symmetric(horizontal: 8.w, vertical: 8.h),
        child: SingleChildScrollView(
          child: Column(
            children: [
              Container(
                decoration: BoxDecoration(
                    color: color210215, borderRadius: 12.r.radius),
                padding: EdgeInsets.symmetric(horizontal: 10.w, vertical: 10.h),
                child: Column(
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Image.asset(Res.common_bottom_tips_icon),
                        10.w.sbw,
                        Text(
                          strTips.tr,
                          style: lfTextStyle(sp: 18.sp, fontFamily: fontMedium),
                        ),
                      ],
                    ),
                    10.h.sbh,
                    Container(
                      height: 2.h,
                      color: color8F8F8F,
                      width: ScreenUtil().screenWidth,
                    ),
                    15.h.sbh,
                    tipWidget ??
                        Text(
                          tips,
                          textAlign: TextAlign.center,
                          style: lfTextStyle(
                            sp: 16.sp,
                            fontFamily: fontMedium,
                            color: color514F62,
                          ),
                        ),
                    15.h.sbh,
                    Padding(
                      padding: EdgeInsets.symmetric(horizontal: 20.w),
                      child: LfButton(
                        enabled: true,
                        enableColor: color210215,
                        text: actionButtonTip ?? strConfirm.tr.toUpperCase(),
                        onPress: () {
                          hideSheet();
                          action.call();
                        },
                      ),
                    ),
                    15.h.sbh
                  ],
                ),
              ),
              10.0.sbh,
              showCancel
                  ? InkWell(
                child: Container(
                    margin: EdgeInsets.symmetric(
                      horizontal: 50.w,
                    ),
                    width: double.infinity,
                    alignment: Alignment.center,
                    padding: EdgeInsets.symmetric(vertical: 15.h),
                    decoration: BoxDecoration(
                        color: colorFEFEFE,
                        borderRadius: BorderRadius.all(Radius.circular(40.h))),
                    child: Text(
                      strCancel.tr,
                      style: lfTextStyle(
                        sp: 16.sp,
                        color: color000000,
                        fontFamily: fontBold,
                      ),
                    )),
                onTap: (){
                  hideSheet();
                },
              )
                  : 0.0.sbh,
            ],
          ),
        ),
      ),
      onWillPop: () async {
        return dismissible;
      },
    ),
    isScrollControlled: dismissible,
    isDismissible: dismissible,
    enableDrag: dismissible,
  );
}
